IAM Roles For ECS
To set up the ECS
we will require 4 types of roles. If you go to IAM -> Roles -> Create Role -> Elastic Container Service
, you will notice the 4 roles use case. We will have to go through each of them and create these roles.
- Role For EC2: Will be attached with to the
EC2
instance. This will allow theECS Agent
to communicate with theECS
andECR
. Create a role namedecsInstanceRole
fromEC2 Role for Elastic Container Service
.
Allows EC2 instances in an ECS cluster to access ECS.
- Role for
ECS
: Will be attached to theECS
. This will allowECS
to manage resources on our behalf. Create a role namedecsRole
fromElastic Container Service
.
Allows ECS to create and manage AWS resources on your behalf.
- Role for
ECS Task
: Will be attached to theECS Task
. This will allow execute the task. Create a role namedecsAutoscalingRole
from theElastic Container Service Autoscale
.
Allows Auto Scaling to access and update ECS services.
- Role for
Auto Scaling
: Only if we use EC2 instance to run docker this role will be required. ForFargate
we will not require any of these. Create a role namedecsTaskExecutionRole
with onlyAmazonECSTaskExecutionRolePolicy
policy fromElastic Container Service Task
.
Allows ECS tasks to call AWS services on your behalf.